package model23.guancha;

import java.util.LinkedList;
import java.util.List;

/**
 * @author ilongsay
 * @date: Create in 2020-03-24 10:02
 */
public class SubjectImpl implements Subject {

    private List<Observer> observers= new LinkedList<>();

    private String data;
    private String level;

    @Override
    public void register(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void remove(Observer observer) {
        observers.remove(observer);
    }

    @Override
    public void notifyObservers() {
        for (Observer observer : observers) {
            observer.update(data,level);
        }
    }

    public void setDataParams(String data, String level) {
        this.data = data;
        this.level = level;
        notifyObservers();
    }
}
